package com.bckj.fastboot.paid.biz.application.service;

import com.bckj.fastboot.core.txasync.TxAsync;
import com.bckj.fastboot.core.txasync.TxAsyncRunner;
import com.bckj.fastboot.paid.api.model.TestTxAsyncModel;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class TestTxAsyncService {
    @Resource
    private TxAsyncRunner txAsyncRunner;

    @TxAsync(taskName = "哈哈哈哈")
    public void test(TestTxAsyncModel model) {
        try {
            System.out.println("test begin... taskId=" + model.getTaskId());
            Thread.sleep(5000);
            System.out.println("test end!");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    public void test3(TestTxAsyncModel model) {
        txAsyncRunner.retry(model.getTaskId());
    }
}
